<?php $this->headTitle('Settings');  ?>
<?php $this->headScript()->appendFile('js/jquery/tab.js'); ?>
<?php $this->headScript()->appendFile('js/jquery/ajaxupload.3.6.js'); ?>

<?php if(!empty($this->returnMessageSuccess)): ?>
<div class="success"><?php echo $this->escape($this->returnMessageSuccess[0]); ?></div>
<?php endif; ?>

<?php if(!empty($this->returnMessageWarning)): ?>
<div class="warning"><?php echo $this->escape($this->returnMessageWarning[0]); ?></div>
<?php endif; ?>

<div class="box">
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('images/setting.png');">Settings</h1>
    <div class="buttons"><a onclick="$('#form').submit();" class="button"><span>Save</span></a></div>
    </div>
  <div class="content">

      <div id="tabs" class="htabs">
            <a tab="#tab_general">General</a>
            <a tab="#tab_mail">Mail</a>
            <a tab="#tab_option">Option</a>
      </div>
      
          <?php echo $this->settingForm->setName('form')->setAttrib('id', 'form'); ?>
  </div>
</div>


<script  type="text/javascript">
  $(document).ready(function() {
    $.tabs('#tabs a');
  });
</script>

<script type="text/javascript">
$(document).ready(function(){

new AjaxUpload('#logo', {
		action: '<?php echo $this->url(array(),'cmsAjaxUpload',true); ?>',
		name: 'image',
		autoSubmit: false,
                responseType: 'json',
		onChange: function(file, extension) {
			this.submit();
		},
		onSubmit: function(file, extension) {
			$('#logo').after('<img src="images/loading.gif" id="loading" style="padding-left: 5px;" />');
		},
		onComplete: function(file, json) {

                        if (json.success) {

                             fileSrc = 'data/images/' + file;

                             $("#logo").attr({src: fileSrc});
                            
                             $("#companyLogo").val(fileSrc);

                        alert(json.success);

                    }

			if (json.error) {
				alert(json.error);
			}

			$('#loading').remove();
		}
	});

 });

</script>